package org.toools.gwt.wmc.client.account;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import java.util.Collection;
import org.toools.gwt.wmc.client.exceptions.dao.EmailExistsException;
import org.toools.gwt.wmc.client.exceptions.dao.WrongLoginException;
import org.toools.gwt.wmc.jpa.Account;

public interface AccountService extends RemoteService {

    public static class Util {
		private static AccountServiceAsync instance;
		public static AccountServiceAsync getInstance(){
			if (instance == null) {
				instance = (AccountServiceAsync) GWT.create(AccountService.class);
				ServiceDefTarget target = (ServiceDefTarget) instance;
				target.setServiceEntryPoint(GWT.getHostPageBaseURL() + "WMC/AccountService");
			}
			return instance;
		}
	}

    /**
     * @param user name (gona be email)
     * @param pwd
     * @return session hash
     * @throws org.toools.gwt.wmc.client.WMCService.WrongLoginException
     */
    Integer login( String email, String pwd ) throws WrongLoginException;
    Boolean logout();
    Integer register( String email, String pwd ) throws EmailExistsException;

    Account getAccountByID( Integer id );
    Collection<Account> getAccounts();

    Boolean delete( Account a );
    Boolean update( Account a );
}